<template>
  <div class="home">
    <div class="btn" @click="savePic">保存图片到相册</div>
    <img class="img" :src="url" alt="" />
  </div>
</template>
<script>
  import Vue from 'vue'
  import { Component } from 'vue-property-decorator'
  @Component({
    name: 'MainView',
    beforeRouteEnter(to, from, next) {
      $setStore('waiting', false)
      next()
    },
  })
  export default class MainView extends Vue {
    url = 'https://img-blog.csdnimg.cn/img_convert/6d6e60cc05d3115a1fa7d84000be6a4d.bmp'
    savePic() {
      android.saveURLToAlbum(this.url)
    }
  }
</script>
<style lang="less" scoped>
  .home {
    width: 100%;

    .btn {
      box-sizing: border-box;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 50px;
      margin: 10px 0;
      color: white;
      cursor: pointer;
      background: blue;
    }

    .img {
      width: 100%;
      height: 300px;
    }
  }
</style>
